using System;
using System.Collections.Generic;
using System.Text;

namespace XnaDevRu.BulletX
{
	/// <summary>
	/// CollisionAlgorithm is an collision interface that is compatible with the Broadphase and Dispatcher.
	/// It is persistent over frames
	/// </summary>
	public abstract class CollisionAlgorithm
	{
		private IDispatcher _dispatcher;
		private readonly int _comparisonID = 0;

		private static int _globalCount = 0;

		public CollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo)
		{
			_comparisonID = _globalCount++;
			_dispatcher = collisionAlgorithmConstructionInfo.Dispatcher;
		}

		protected IDispatcher Dispatcher { get { return _dispatcher; } set { _dispatcher = value; } }
		internal int ComparisonID { get { return _comparisonID; } }

		public abstract void ProcessCollision(CollisionObject colA, CollisionObject colB, DispatcherInfo dispatchInfo, ManifoldResult resultOut);
		public abstract float CalculateTimeOfImpact(CollisionObject colA, CollisionObject colB, DispatcherInfo dispatchInfo, ManifoldResult resultOut);
	}
}
